package ch.myDungeons.io;

public class LanguagePack {
	public static String currentLanguage = "english";
	private static String[] languageData;
	
	static{
		loadLanguage(currentLanguage);
	}
	
	public static void loadLanguage(String language){
		currentLanguage = language;
		String languageString = IOStream.loadLanguageFile(language);
		languageString = languageString.replaceAll(" =", "=");
		languageString = languageString.replaceAll("= ", "=");
		languageData = languageString.split("\n");
	}
	
	public static String get(String string){
		String result = string;
		string = string.toLowerCase();
		for (int i = 0; i < languageData.length; i++) {
			if (languageData[i].startsWith(string + "=")) {
				result = languageData[i].substring(string.length() + 1);
			}
		}
		return result;
	}
	
	/** Capitalizes the first letter of the string */
	public static String capitalizeString(String str){
		if(str.length() > 0){
			str = str.substring(0,1).toUpperCase() + str.substring(1);
		}
		return str;
	}
}
